package com.bop.dehong.adapter;

import java.util.ArrayList;
import java.util.List;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;
import android.view.ViewGroup;
/**
 * 有状态的FragmentAdapter ，只会有前3个存在 其他销毁，  前1个， 中间， 下一个,这样适合滑动
 * @author Tangwenhan
 *
 */
public class MyFragStatePagerAdapter extends FragmentStatePagerAdapter{
	
	private List<Fragment> mFragments = new ArrayList<Fragment>();
	
	public MyFragStatePagerAdapter(FragmentManager fm,List<Fragment> fragments) {
		super(fm);
		mFragments = fragments;
	}

	@Override
	public Fragment getItem(int i) {
		// TODO Auto-generated method stub
		return mFragments.size() > i ? mFragments.get(i):null;
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return mFragments.size();
	}

	@Override
	public Object instantiateItem(ViewGroup container, int position) {
		return super.instantiateItem(container, position);
	}
	
	

}
